﻿
using System;
using System.Runtime.InteropServices;
namespace YoucaiReader.ImageTool
{
    [StructLayout(LayoutKind.Sequential)]
    public class Rectangle : IEquatable<Rectangle>
    {
        public static readonly Rectangle Zero = new Rectangle(0, 0, 0, 0);
        private int _height;
        private int _width;
        private int _x;
        private int _y;
        public int Bottom
        {
            get
            {
                return (this._y + this._height);
            }
        }
        public int Height
        {
            get
            {
                return this._height;
            }
            set
            {
                this._height = value;
            }
        }
        public int Left
        {
            get
            {
                return this._x;
            }
        }
        public int Right
        {
            get
            {
                return (this._x + this._width);
            }
        }
        public int Top
        {
            get
            {
                return this._y;
            }
        }
        public int Width
        {
            get
            {
                return this._width;
            }
            set
            {
                this._width = value;
            }
        }
        public int X
        {
            get
            {
                return this._x;
            }
            set
            {
                this._x = value;
            }
        }
        public int Y
        {
            get
            {
                return this._y;
            }
            set
            {
                this._y = value;
            }
        }
        public Rectangle(int x, int y, int width, int height)
        {
            this._x = x;
            this._y = y;
            this._width = width;
            this._height = height;
        }

        public Rectangle(Rectangle other)
            : this(other.X, other.Y, other.Width, other.Height)
        {
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }
            bool flag = false;
            if (obj is Rectangle)
            {
                flag = this.Equals((Rectangle)obj);
            }
            return flag;
        }

        public bool Equals(Rectangle other)
        {
            return ((((this._x == other._x) && (this._y == other._y)) && (this._width == other._width)) && (this._height == other._height));
        }

        public override int GetHashCode()
        {
            return (((this.X ^ this.Y) ^ this.Width) ^ this.Height);
        }

        public static bool operator ==(Rectangle left, Rectangle right)
        {
            return left.Equals(right);
        }

        public static bool operator !=(Rectangle left, Rectangle right)
        {
            return !left.Equals(right);
        }
    }
}

